﻿using Microsoft.AspNetCore.Mvc;
using PowerHub.MES.Entities.BasicData;
using PowerHub.MES.Entities;
using PowerHub.MES.ReturnEntity;
using Microsoft.AspNetCore.Authorization;
using PowerHub.MES.Jwt;
using System.Security.Claims;
using PowerHub.MES.DTO.BasicData.QueryDto;
using PowerHub.MES.Services.Basic;
using PowerHub.MES.IServices.IBasic;
using PowerHub.MES.DTO.BasicData.DTO;
using System.ComponentModel;
using PowerHub.MES.Common.Utility;

namespace PowerHub.MES.Controllers.Basic
{
    [ApiController]
    [Route("Api/MES/Basic/[controller]/[action]")]
    public class UserinfoController
    {
        //数据库上下文
        public JwtService _jwtService;
        public UserServices _userServices;
        public IBasicDataUserinfoServices _IbasicDataUserinfoServices;
        public UserinfoController(JwtService jwtService, UserServices userServices, IBasicDataUserinfoServices basicDataUserinfoBLL)
        {
            _jwtService = jwtService;
            _userServices = userServices;
            _IbasicDataUserinfoServices = basicDataUserinfoBLL;
        }


        /// <summary>
        /// 获取用户列表
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        [HttpPost]
        [FunctionDescription("获取用户列表")]
        public async Task<OperationPageResult<List<BasicData_Userinfo>>> GetBasicData_UserinfoPageListAsync([FromBody] QueryBasicData_UserinfoDTO pageQuery)
        {
            return await _IbasicDataUserinfoServices.GetBasicData_UserinfoPageListAsync(pageQuery);
        }

        /// <summary>
        /// 更新用户
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        [HttpPost]
        [FunctionDescription("更新用户")]
        public async Task<OperationResult<object>> UpdateBasicData_UserinfoAsync([FromBody] BasicData_UserinfoDTO Query)
        {
            return await _IbasicDataUserinfoServices.UpdateBasicData_UserinfoAsync(Query);
        }

        /// <summary>
        /// 批量删除用户
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        [HttpPost]
        [FunctionDescription("批量删除用户")]
        public async Task<OperationResult<object>> BatchDeletionBasicData_UserinfoAsync([FromBody] List<string> Query)
        {
            return await _IbasicDataUserinfoServices.BatchDeletionBasicData_UserinfoAsync(Query);
        }

        /// <summary>
        /// 添加用户
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        [HttpPost]
        [FunctionDescription("添加用户")]
        public async Task<OperationResult<object>> CreateBasicData_UserinfoAsync([FromBody] BasicData_UserinfoDTO Query)
        {
            return await _IbasicDataUserinfoServices.CreateBasicData_UserinfoAsync(Query);
        }
        /// <summary>
        /// 登录
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [AllowAnonymous]
        [FunctionDescription("登录")]
        public async Task<OperationResult<string>> GetBasicData_UserinfoLogin([FromBody] QueryBasicData_UserinfoDTO query_BasicData_UserinfoDTO)
        {
            return await _IbasicDataUserinfoServices.apiLogin(query_BasicData_UserinfoDTO);
        }
    }
}
